<template>
  <view class="content">
    <downloadPop :file_path="file_path"></downloadPop>
    <view class="section-0">
      <view class="section-body">
        <view class="item">
          <view class="title">初步设计单位</view>
          <view class="name">
            <view class="name-text">
              {{ psObj.feasibility_design_unit }}
            </view>
          </view>
        </view>
        <!-- <view class="item" >
					<view class="title">图纸交付时间</view>
					<view class="name">
						<view class="name-text">
							{{psObj.design_time.split(" ")[0]}}
						</view>
					</view>
				</view> -->
        <!-- <view class="item" > -->

        <view class="time-line">
          <view
            class="time-line-item"
            v-for="(item, idx) in list"
            :key="idx"
          >
            <view class="left">
              <view class="circle"></view>
            </view>
            <view class="right">
              <view class="title">
                {{ item.title }}
              </view>
              <!-- <view class="time-line-content" @click="handleShowTime(idx)"> -->
				<view class="time-line-content">
                <view class="text">
                  {{ item.value }}
                </view>
              </view>
            </view>
          </view>
        </view>
<!-- 
        <view class="item">
          <view class="title">附件下载</view>
          <view class="file-content">
            <view class="file-item">
              <text class="label">预审意见</text><text>：</text>
              <text class="iconfont icon-huixingzhen"></text>
              <text class="file-name" @click="ysDownLoad(psObj.ys_file_path)">
                {{ psObj.ys_file_name }}
              </text>
            </view>
            <view class="file-item">
              <text class="label">内审意见</text><text>：</text>
              <text class="iconfont icon-huixingzhen"></text>
              <text class="file-name" @click="nsDownLoad(psObj.ns_file_path)">
                {{ psObj.ns_file_name }}
              </text>
            </view>
            <view class="file-item">
              <text class="label">外审意见</text><text>：</text>
              <text class="iconfont icon-huixingzhen"></text>
              <text class="file-name" @click="wsDownLoad(psObj.ws_file_path)">
                {{ psObj.ws_file_name }}
              </text>
            </view>
            <view class="file-item" style="margin-bottom: 10rpx">
              <text class="label">初步设计批复</text><text>：</text>
              <text class="iconfont icon-huixingzhen"></text>
              <text class="file-name" @click="cbDownLoad(psObj.cb_file_path)">
                {{ psObj.cb_file_name }}
              </text>
            </view>
            <view class="file-item" style="margin-bottom: 10rpx">
              <text class="label">新技术应用</text><text>：</text>
              <text class="iconfont icon-huixingzhen"></text>
              <text class="file-name" @click="xjsDownLoad(psObj.xjs_file_path)">
                {{ psObj.xjs_file_name }}
              </text>
            </view>
          </view>
        </view> -->

        <!-- <view class="item-2" @click="go()">
					<view class="left">
						<view class="name">初步设计图纸管理</view>
					</view>
					<view class="right">
						<text class="iconfont icon-xiangyou1"></text>
					</view>
				</view> -->
        <!-- <view class="submit" @click="submit()"> 提交 </view> -->
      </view>
    </view>
  </view>
</template>

<script>
import downloadPop from "@/components/download_pop/index.vue";
import {
  reviewDetailApi,
  projectReviewEditApi,
  getFeasibilitydata
} from "../../../../../api/project_manage.js";
import { mapGetters } from "vuex";
export default {
  components: {
    downloadPop,
  },
  data() {
    return {
      file_path: "",
      list: [],
      showStart: false,
      startStamp: 0,
      curIdx: 3,
      psObj: {},
    //   contentList: [
    //     {
    //       title: "初设状态",
    //       value: "未内审",
    //     },
    //     {
    //       title: "初设设计情况",
    //       value: "未内审",
    //     },
    //     {
    //       title: "初设内审时间",
    //       value: "未内审",
    //     },
    //     {
    //       title: "初设评审时间",
    //       value: "未内审",
    //     },
    //     {
    //       title: "初设评审意见号",
    //       value: "未内审",
    //     },
    //     {
    //       title: "初设设计批复文号",
    //       value: "未内审",
    //     },
    //   ],
    };
  },
  computed: {
    ...mapGetters({
      curProject: "system/getCurProject",
    }),
  },
  methods: {
    // 附件下载
    ysDownLoad(url) {
      this.file_path = "";
      setTimeout(() => {
        this.file_path = url;
      }, 0);
    },
    nsDownLoad(url) {
      this.file_path = "";
      setTimeout(() => {
        this.file_path = url;
      }, 0);
    },
    wsDownLoad(url) {
      this.file_path = "";
      setTimeout(() => {
        this.file_path = url;
      }, 0);
    },
    cbDownLoad(url) {
      this.file_path = "";
      setTimeout(() => {
        this.file_path = url;
      }, 0);
    },
    xjsDownLoad(url) {
      this.file_path = "";
      setTimeout(() => {
        this.file_path = url;
      }, 0);
    },
    go() {
      uni.navigateTo({
        url: "/pages/work/manager/engineering_prev/review/draw/info/index",
      });
    },
    formatDate(timeStamp) {
      const date = new Date(timeStamp); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
      const Y = date.getFullYear() + "-";
      const M =
        (date.getMonth() + 1 < 10
          ? "0" + (date.getMonth() + 1)
          : date.getMonth() + 1) + "-";
      const D = date.getDate();
      const h = date.getHours() + ":";
      const m = date.getMinutes() + ":";
      const s = date.getSeconds();
      return Y + M + D;
    },
    confirmStart(val) {
      let arr = this.list.slice(0);
      const timeStamp = val.value;
      this.showStart = false;
      arr[this.curIdx].value = this.formatDate(timeStamp);
      this.list = arr;
      this.curIdx++;
    },
    handleShowTime(idx) {
      this.curIdx = idx;
      this.showStart = true;
    },
    // 提交
    async submit() {
      const obj = {};
      // obj.id=this.psObj.id
      obj.project_id = this.curProject.id;
      if (this.psObj.sj_dw) {
        obj.sj_dw = this.psObj.sj_dw;
      }
      if (this.list[0].value) {
        obj.ys_time = this.list[0].value;
      }
      if (this.list[1].value) {
        obj.ns_time = this.list[1].value;
      }
      if (this.list[2].value) {
        obj.oper_time = this.list[2].value;
      }
      if (this.list[3].value) {
        obj.ws_time = this.list[3].value;
      }
      if (this.list[4].value) {
        obj.file_time = this.list[4].value;
      }
      if (this.list[5].value) {
        obj.pf_time = this.list[5].value;
      }
      console.log(obj);
      const { data } = await projectReviewEditApi(obj);
      console.log(data, "请求成功");
      if (data.code == 1) {
        uni.showToast({
          title: "操作成功",
          duration: 1000,
          icon: "success",
        });
        uni.hideLoading();
        this.$refs.problemList.initData();
      } else {
        uni.showToast({
          title: "操作失败",
          duration: 1000,
          icon: "error",
        });
        uni.hideLoading();
      }
    },
  },
  async onReady() {
    this.startStamp = new Date().valueOf();
    for (let i = 0; i < this.list; i++) {
      if (this.list[i].value === "") {
        this.curIdx = i;
        break;
      }
    }
  
	const { data } = await getFeasibilitydata({
      project_id: this.curProject.id,
    });
    console.log(data, "查看数据");
	  if (data.code == 1 || data.code == 200) {
      this.psObj = data.data;
      this.list = [
        {
          title: "初设状态",
          value: data.data.preliminary_design_status ? data.data.preliminary_design_status : "_",
        },
        {
          title: "初设设计情况",
          value: data.data.preliminary_design_content ? data.data.preliminary_design_content : "_",
        },
        {
          title: "初设内审时间",
          value: data.data.design_check_time
            ? data.data.design_check_time.substring(0, 10)
            : "_",
        },
        {
          title: "初设评审时间",
          value: data.data.design_up_reply ? data.data.design_up_reply.substring(0, 10) : "_",
        },
        {
          title: "初设评审意见号",
          value: data.data.review_comment_no
            ? data.data.review_comment_no
            : "_",
        },
        {
          title: "初设设计批复文号",
          value: data.data.preliminary_approval_no ? data.data.preliminary_approval_no : "_",
        },
      ];
    }
  },
};
</script>

<style lang="scss" scoped>
.section-0 {
  width: 100%;
  background-color: #3a5df5;

  .section-body {
    padding-top: 50rpx;
    box-sizing: border-box;
    width: 100%;
    padding-left: 40rpx;
    padding-right: 40rpx;
    padding-bottom: 50rpx;
    background-color: #fff;
    background-size: cover;
    background-repeat: no-repeat;
    border-top-left-radius: 50rpx;
    border-top-right-radius: 50rpx;

    .time-line {
      width: 100%;
      box-sizing: border-box;
      padding: 40rpx;
      // width: 100%;
      padding-bottom: 10rpx;
      background-color: #ffffff;
      border-radius: 35rpx;
      box-shadow: 0 0 20rpx 10rpx rgba(#bcbcb5, 0.17);
      margin-bottom: 28rpx;

      .time-line-item {
        width: 100%;
        min-height: 60rpx;
        @include clear();
        position: relative;

        &:last-child {
          .left {
            &::before {
              display: none;
            }
          }
        }

        .left {
          float: left;
          width: 20rpx;
          position: absolute;
          left: 0;
          top: 0;
          height: 100%;

          &::before {
            content: "";
            width: 1rpx;
            height: 100%;
            position: absolute;
            left: 10rpx;
            top: 20rpx;
            border-left: 1rpx dashed #0036df;
          }

          .circle {
            width: 20rpx;
            height: 20rpx;
            background-color: #0036df;
            border: solid 1rpx #ffffff;
            border-radius: 50%;
          }
        }

        .right {
          float: left;
          margin-left: 45rpx;
          width: calc(100% - 20rpx - 25rpx);

          .title {
            line-height: 30rpx;
            font-size: 26rpx;
            font-weight: normal;
            font-stretch: normal;
            letter-spacing: 0rpx;
            color: #7f98ae;
            margin-bottom: 20rpx;
          }

          .time-line-content {
            width: 300rpx;
            display: flex;
            float: left;
            margin-bottom: 26rpx;

            .text {
              font-size: 26rpx;
              font-weight: bold;
              font-stretch: normal;
              line-height: 30rpx;
              letter-spacing: 0rpx;
              color: #46464a;
              margin-right: 20rpx;
            }

            .form-item {
              width: 260rpx;
              height: 48rpx;
              position: relative;
              top: -9rpx;
              border-radius: 20rpx;
              border: solid 2rpx #1534ce;
              margin: 0 auto;
              @include clear();

              .input {
                width: 100%;

                .input-body {
                  box-sizing: border-box;
                  width: 100%;
                  height: 44rpx;
                  line-height: 44rpx;
                  padding: 0 !important;
                  border: none;
                  padding-left: 30rpx !important;
                  padding-right: 30rpx !important;
                  font-size: 26rpx;
                  font-weight: normal;
                  font-stretch: normal;
                  letter-spacing: 0rpx;
                  color: rgba(0, 0, 0, 0.7);
                }

                .input-placeholder {
                  font-size: 26rpx;
                  font-weight: normal;
                  font-stretch: normal;
                  letter-spacing: 0rpx;
                  color: rgba(0, 0, 0, 0.5);
                }
              }

              position: relative;

              .iconfont {
                position: absolute;
                right: 25rpx;
                top: 7rpx;
                font-size: 30rpx;
                color: #dad9df;
              }
            }
          }
        }
      }
    }

    .item-2 {
      width: 100%;
      height: 100rpx;
      background-color: #ffffff;
      border-radius: 35rpx;
      box-shadow: 0 0 20rpx 10rpx rgba(#bcbcb5, 0.17);
      box-sizing: border-box;
      padding: 30rpx;
      @include clear();
      margin-bottom: 28rpx;

      .left {
        float: left;
        width: 520rpx;

        .name {
          height: 40rpx;
          width: 100%;
          font-size: 26rpx;
          font-weight: bold;
          font-stretch: normal;
          line-height: 40rpx;
          letter-spacing: 0rpx;
          // color: #46464a;
          color: #dad9df;
        }
      }

      .right {
        width: 20rpx;
        float: right;
        height: 40rpx;
        line-height: 40rpx;
        // color: #3b3c40;
        color: #dad9df;

        .iconfont {
          font-size: 32rpx;
        }
      }
    }

    .item {
      width: 100%;
      padding-bottom: 10rpx;
      background-color: #ffffff;
      border-radius: 35rpx;
      box-shadow: 0 0 20rpx 10rpx rgba(#bcbcb5, 0.17);
      margin-bottom: 28rpx;

      .file-tips {
        width: 100%;
        height: 80rpx;
        line-height: 80rpx;
        color: #8497ac;
        font-size: 26rpx;
        box-sizing: border-box;
        padding-left: 35rpx;
      }

      .file-content {
        width: 533rpx;
        margin-left: 35rpx;
        padding-top: 22rpx;
        padding-bottom: 22rpx;

        // border-bottom: solid 3rpx #f2f2f0;
        .file-list {
          @include clear();

          .file-list-item {
            width: 50%;
            float: left;
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
            height: 40rpx;
            line-height: 40rpx;
            box-sizing: border-box;
            padding-right: 20rpx;

            .iconfont {
              font-size: 26rpx;
              color: #1d33c6;
              margin-right: 5rpx;
            }

            .file-name {
              font-size: 26rpx;
              font-weight: bold;
              color: #1d33c6;
            }
          }
        }

        .file-item {
          width: 100%;
          font-size: 26rpx;
          margin-bottom: 16rpx;

          &:last-child {
            margin-bottom: 0;
          }

          .label {
            width: 180rpx;
            color: #46464a;
            font-weight: bold;
            display: inline-block;
            text-align: justify;
            text-align-last: justify;
          }

          .iconfont {
            font-size: 26rpx;
            color: #1d33c6;
            margin-right: 5rpx;
          }

          .file-name {
            font-weight: bold;
            color: #1d33c6;
          }
        }
      }

      .file-content {
      }

      .title {
        width: 533rpx;
        height: 50rpx;
        padding-top: 15rpx;
        line-height: 50rpx;
        border-bottom: solid 3rpx #f2f2f0;
        font-size: 26rpx;
        font-weight: normal;
        font-stretch: normal;
        letter-spacing: 0rpx;
        color: #8497ac;
        margin-left: 35rpx;
      }

      .name {
        box-sizing: border-box;
        padding: 0 35rpx;
        width: 100%;
        @include clear();

        .name-text {
          width: 520rpx;
          height: 80rpx;
          line-height: 80rpx;
          font-size: 26rpx;
          font-weight: normal;
          font-stretch: normal;
          letter-spacing: 0rpx;
          color: #46464a;
          float: left;
          text-overflow: ellipsis;
          overflow: hidden;
          font-weight: bold;
          white-space: nowrap;
          display: flex;

          .input-body {
            box-sizing: border-box;
            width: 100%;
            height: 44rpx;
            padding: 0 !important;
            border: none;
            padding-top: 30rpx !important;
            padding-right: 30rpx !important;
            font-size: 26rpx;
            font-weight: normal;
            font-stretch: normal;
            letter-spacing: 0rpx;
            color: rgba(0, 0, 0, 0.7);
          }
        }

        .name-text__file {
          color: #0535d6;
        }
      }
    }
  }

  .submit {
    width: 287rpx;
    height: 83rpx;
    margin: 0 auto;
    background-color: #1534ce;
    border-radius: 20rpx;
    letter-spacing: 14rpx;
    color: #ffffff;
    font-size: 26rpx;
    display: flex;
    justify-content: center;
    align-items: center;
  }
}
</style>
